package jm.demo.je;

import com.sleepycat.bind.serial.ClassCatalog;
import com.sleepycat.collections.StoredMap;
import com.sleepycat.je.Database;
import com.sleepycat.je.Environment;

public class JeConnection<K, V> {

    private Environment environment;
    private Database database;
    private ClassCatalog catalog;
    private StoredMap<K, V> map;
    
    
    public JeConnection() {
        super();
    }
    
    
    
    
    public JeConnection(Environment environment, Database database,
            ClassCatalog catalog, StoredMap<K, V> map) {
        super();
        this.environment = environment;
        this.database = database;
        this.catalog = catalog;
        this.map = map;
    }




    public Environment getEnvironment() {
        return environment;
    }


    public void setEnvironment(Environment environment) {
        this.environment = environment;
    }


    public Database getDatabase() {
        return database;
    }


    public void setDatabase(Database database) {
        this.database = database;
    }


    public ClassCatalog getCatalog() {
        return catalog;
    }


    public void setCatalog(ClassCatalog catalog) {
        this.catalog = catalog;
    }


    public StoredMap<K, V> getMap() {
        return map;
    }


    public void setMap(StoredMap<K, V> map) {
        this.map = map;
    }


    public void close() {
        if (database != null) {
            database.close();
            database = null;
        }
        if (catalog != null) {
            catalog.close();
            catalog = null;
        }
        if (environment != null) {
            environment.close();
            environment = null;
        }

    }
}
